#define _CRT_SECURE_NO_WARNINGS 1

#include <vector>
using namespace std;

class Solution {
public:
    vector<int> missingTwo(vector<int>& nums) {
        int tmp = 0;
        for (int i = 1; i <= nums.size() + 2; ++i)
            tmp ^= i;
        for (auto e : nums)
            tmp ^= e;
        int diff = 0;
        while (1)
        {
            if ((tmp >> diff) & 1) break;
            else ++diff;
        }
        int a = 0, b = 0;
        for (auto e : nums)
            if ((e >> diff) & 1) a ^= e;
            else b ^= e;
        for (int i = 1; i <= nums.size() + 2; ++i)
            if ((i >> diff) & 1) a ^= i;
            else b ^= i;
        return { a,b };
    }
};